/*
 * TeacherPhoneDbSaverTests.cpp
 *
 *  Created on: 06 ���� 2010
 *      Author: Sartios
 */

#include "TeacherPhoneDbSaverTests.h"

#include "../../../../DAO/Savers/TeacherPhoneSavers/DbSaver/TeacherPhoneDbSaver.h"

#include "../../../../Utilities/SymbolsProvider/SymbolsProviderSingleton.h"

void	TeacherPhoneDbSaverTests::setUp(){
	phoneSaver_ = new TeacherPhoneDbSaver;
}

void	TeacherPhoneDbSaverTests::tearDown(){
	delete phoneSaver_;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_CorrectParameters_ReturnTrue(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("2375012113");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should pass because the inputs are proper",true==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_InsuranceNumberDoesNotExist_ReturnFalse(){
	string	*insuranceNumber = new string("0000000000");
	string	*number = new string("2375011112");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because owner's insurance number doesn't exists",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_CharactersAsPhoneNumber_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("six nine eight");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because number contains characters",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_CategoryDoesNotExist_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("2375011113");
	string	*category = new string("chill");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because category does not exist",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_NullAsInputs_ReturnFalse(){
	string	*insuranceNumber = NULL;
	string	*number = NULL;
	string	*category = NULL;

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because the inputs are NULL",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_NullAsOwnersInsuranceNumber_ReturnFalse(){
	string	*insuranceNumber = NULL;
	string	*number = new string("2375011114");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because owner's insurance in NULL",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_NullAsTelephoneNumber_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = NULL;
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because telephone number is NULL",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_NullAsCategory_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("2375011115");
	string	*category = NULL;

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because category is NULL",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_SymbolsAsNumber_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string(*SymbolsProviderSingleton::getInstance()->getSymbols());
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because number contains symbols",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_SymbolsAsCategory_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("2375011116");
	string	*category =new string(*SymbolsProviderSingleton::getInstance()->getSymbols());

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because category contains symbols",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_NegativeAsTelephoneNumber_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("-2375011117");
	string	*category = new string(*SymbolsProviderSingleton::getInstance()->getSymbols());

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because phone is a negative number",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_BlankInsuranceNumber_ReturnFalse(){
	string	*insuranceNumber = new string(" ");
	string	*number = new string("2375011118");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fails because insurance number is blank",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_BlankPhoneNumber_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string(" ");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because telephone number is blank",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_BlankPhoneCategory_ReturnFalse(){
	string	*insuranceNumber = new string("0123456789");
	string	*number = new string("2375011119");
	string	*category = new string(" ");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because telephone category is blank",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_CharactersAsInsuranceNumber_ReturnFalse(){
	string	*insuranceNumber = new string("ten eleven");
	string	*number = new string("2375022222");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because insurance number has characters",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_SymbolsAsInsuranceNumber_ReturnFalse(){
	string	*insuranceNumber = new string(*SymbolsProviderSingleton::getInstance()->getSymbols());
	string	*number = new string("2375011121");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(insuranceNumber,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because insurance number has symbols",false==result);

	delete insuranceNumber;
	delete number;
	delete category;
}

void	TeacherPhoneDbSaverTests::saveTeacherPhone_InsuranceNumberEqualToZero_ReturnFalse(){
	string	*ZERO = new string("0");
	string	*number = new string("2375011111");
	string	*category = new string("home");

	bool	result = phoneSaver_->saveTeacherPhone(ZERO,number,category);

	CPPUNIT_ASSERT_MESSAGE("Should fail because zero is not a valid insurance number",false==result);

	delete ZERO;
	delete number;
	delete category;
}
